package manage.model;

import m.common.model.FieldMeta;
import m.common.model.LinkTableMeta;
import m.common.model.SessionModel;
import m.common.model.TableMeta;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryUtil;

import java.util.Date;

@TableMeta(name="os_admin_assist",description="管理员协助账号表")
public class AdminAssist extends StatusModel implements SessionModel {

    @LinkTableMeta(name="admin_oid",table=AdminLogin.class,description="所属管理员")
    private AdminLogin admin;

    @FieldMeta(name="token",type= FieldType.STRING,length=100,description="token")
    private String token;
    @FieldMeta(name="realname",type=FieldType.STRING,length=20,notnull=true,description="真实姓名")
    private String realname;
    @FieldMeta(name="username",type=FieldType.STRING,length=20,notnull=true,description="登录帐号")
    private String username;
    @FieldMeta(name="password",type=FieldType.STRING,length=50,notnull=true,description="登录密码")
    private String password;
    @FieldMeta(name="create_date",type=FieldType.DATE,description="创建时间")
    private Date createDate;
    @FieldMeta(name="last_login_time",type=FieldType.DATE,description="最后登录时间")
    private Date lastLoginTime;
    @FieldMeta(name="last_login_ip",type=FieldType.STRING,length=20,description="最后登录IP")
    private String lastLoginIp;
    @FieldMeta(name="login_count",type=FieldType.INT,description="登陆次数")
    private Integer loginCount;
    @LinkTableMeta(name="org_group_oid",table=OrgGroupView.class,description="登录机构")
    private OrgGroupView orgGroup;

    public OrgGroupView getOrgGroup() {
        return orgGroup;
    }

    public void setOrgGroup(OrgGroupView orgGroup) {
        this.orgGroup = orgGroup;
    }

    public AdminLogin getAdmin() {
        return admin;
    }

    public void setAdmin(AdminLogin admin) {
        this.admin = admin;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getRealname() {
        return realname;
    }

    public void setRealname(String realname) {
        this.realname = realname;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Date getLastLoginTime() {
        return lastLoginTime;
    }

    public void setLastLoginTime(Date lastLoginTime) {
        this.lastLoginTime = lastLoginTime;
    }

    public String getLastLoginIp() {
        return lastLoginIp;
    }

    public void setLastLoginIp(String lastLoginIp) {
        this.lastLoginIp = lastLoginIp;
    }

    public Integer getLoginCount() {
        return loginCount;
    }

    public void setLoginCount(Integer loginCount) {
        this.loginCount = loginCount;
    }

    @Override
    public AdminAssist getCacheModel(String key) throws Exception {
        AdminAssist admin=new AdminAssist();
        admin.setOid(key);
        return ModelQueryUtil.getModel(admin);
    }
}
